<?php

	
    $companies = $userObj->fetch_result("SELECT user_shops.* FROM user_shops JOIN  user ON user.id = user_shops.user_id WHERE user.session_user='{$_SESSION['client']['login_key']}' ");
   
?>

		<div id='table_products_wrapper'>
<!--			<a href='<?php //echo SERVER_PATH."product/new.html" ?>' class='btn btn-primary btn-success'>+<?php  //echo translate_word_shop('Add_company',$dictionary); ?></a>-->
		
				<table id="products" class="table table-striped table-bordered table-hover">
					<thead>
						<tr>																	
							<th><?php  echo translate_word_shop('Company',$dictionary); ?></th>
							<th><?php  echo translate_word_shop('Url',$dictionary); ?></th>
							<th><?php  echo translate_word_shop('County',$dictionary); ?></th>
							<th><?php  echo translate_word_shop('City',$dictionary); ?></th>
							<th><?php  echo translate_word_shop('Buisness_type',$dictionary); ?></th>
							<th><?php  echo translate_word_shop('creation_date',$dictionary); ?></th>
							<th><?php  echo translate_word_shop('Products_number',$dictionary); ?></th>
							<th><?php  echo translate_word_shop('Active',$dictionary); ?></th>
							<th><?php  echo translate_word_shop('Actions',$dictionary); ?></th>
						</tr>
					</thead>

					<tbody>
						<?php 

							foreach ($companies as $key => $value) {							
								
								$county = $userObj->fetch_one("SELECT name FROM counties WHERE id='{$value['county_id']}'");
								$city = $userObj->fetch_one("SELECT name FROM cities WHERE id='{$value['city_id']}'");

								if($value['active']==1){
									$visible = "checked='checked'";
								}else{
									$visible ='';
								}
								if($value['business_type']==1){
								    $business_type = translate_word_shop("Producator");
								}else if($value['business_type']==2){
								    $business_type = translate_word_shop("Distribuitor");
								}else{
								     $business_type = translate_word_shop("Furnizor");
								}
								$creation_date =date("d-m-Y",$value['creation_date']);
								$nr_products=0; 
								echo "<tr>										
										<td><a href ='".scripts_url()."profil/company/{$value['url']}.html'>{$value['name']}</td>
										<td>{$value['url']}</td>
										<td>{$county['name']}</td>
										<td>{$city['name']}</td>
										<td>{$business_type}</td>
										<td>{$creation_date}</td>
										<td>{$nr_products}</td>
										<td><input type ='checkbox' onclick ='check_company(\"active\",{$value['id']},this)' {$visible}><span class='lbl'></span></td>
										<td>
								        <a class='green' href ='".scripts_url()."profil/company/{$value['url']}.html'>
										<i class='icon-pencil bigger-130'></i>
									</a>

									<a class='red' href='javascript:void(0)' onclick='delete_product({$value['id']},this)'>
										<i class='icon-trash bigger-130'></i>
									</a>

									
										</td>
									 </tr>";
							}

						 ?>
						


					</tbody>
				</table>
			</div>
			<div id="modal-import" class="modal hide fade"  tabindex="-1">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button class="close" data-dismiss="modal" type="button">×</button>
						<?php echo translate_word_shop('Import stocks',$dictionary); ?>
					</div>		
					<form metho='POST' action='http://www.neo-flux.com/wizard/products.html' name='csv_form' id='csv_form' enctype="multipart/form-data">			
						<input type="file" name="file_upload_pics" id="file_upload_pics" />
						<!-- <input type='text' namame ='mergi'> -->
						<!-- <input type='submit' class="btn btn-small btn-danger btn-primary"  value='Save' > -->
					</form>
				</div>	
				<br class='clear'/>
				<div class="modal-footer ">					
					<button class="btn btn-small btn-danger btn-primary" data-dismiss="modal" onclick = "$('#csv_form').submit();">Save</button>
					<button class="btn btn-small btn-danger btn-primary" data-dismiss="modal">Cancel</button>
				</div>
				
			</div>